<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        function getValue()
          {
          var x=document.getElementById("myHeader")
          //innerHTML 显示节点元素的纯文本内容
          alert(x.innerHTML)
          }
        </script>
</head>
<body>
    <h1 id="myHeader" onclick="getValue()">This is a header</h1>
    <p>Click on the header to alert its value</p>
</body>
</html>